import { isNumber } from '@fl/utils/validate'
import { reactive } from 'vue'

export function useRule() {
    const validatorLevelNo = (rule, value, callback) => {
        if (!value || !isNumber(value))
            callback(new Error('请输入数字'))
        else callback()
    }

    const rules = reactive<any>({
        levelIcon: [
            { message: '请上传图片', required: true, trigger: 'blur' },
        ],
        levelImg: [
            { message: '请上传图片', required: true, trigger: 'blur' },
        ],
        levelName: [
            { message: '请输入', required: true, trigger: 'blur' },
        ],
        levelNo: [
            { required: true, trigger: 'blur', validator: validatorLevelNo },
        ],

    })

    return { rules }
}
